from lxml import etree
import requests


with open('static/Go底层原理面试题.html', 'r', encoding='utf-8') as f:
    html = f.read()

tree = etree.HTML(html)
#解析html数据
tr_list = tree.xpath('//*[@id="bankDetailPage"]/div[3]/div/div/div/div[2]/div/div/div/div/div/table/tbody/tr')
count = 0

with open('file/Go底层原理面试题.txt', 'w', encoding='utf-8') as f:
    for tr in tr_list:
        question_name = tr.xpath('td/a/text()') # tr[@class="ant-table-row ant-table-row-level-0"]
        count += 1
        if not question_name:
            continue
        print(question_name[0])
        f.write(question_name[0] + '\n')
    print(count)
